#!/usr/bin/python
# -*- coding: utf-8 -*-
import multiprocessing
import threading

class DaemonType(object):
    PROCESS = 'process'
    THREAD = 'thread'
        
# Daemon Factory
class DaemonFactory(object):
    @staticmethod
    def get_daemon(name, function, arguments, daemon_type=DaemonType.THREAD):
        if daemon_type in [DaemonType.PROCESS]:
            p = multiprocessing.Process(target=function, name=name, args=arguments)
            p.daemon = False
            return p
        else:
            t = threading.Thread(target=function, name=name, args=arguments)
            t.daemon = True
            return t
